/*
 * 
 */
function Hero (name,hp,mp,attack,defeat) {
	this.name = name;
	this.hp = hp;
	this.mp = mp;
	this.attack = attack;
	this.defeat = defeat;
	this.ming = 50;
	this.shan = 20;
}

function Skill (name,shanghai,mp) {
	this.name = name;
	this.shanghai = shanghai;
	this.mp = mp;
}
Hero.prototype.attackFn = function(target,skill){
	var shanghai = 0;
	if (true) {
		//打到了
		if (this.mp >= skill.mp) {	//蓝够 放技能
			this.mp -= skill.mp;
			shanghai = skill.shanghai - target.defeat;
			target.beidaFn('技能'+skill.name+'攻击了'+shanghai+'点生命');
		}else{	//蓝不够 普通攻击
			shanghai = parseInt(Math.random()*this.attack - Math.random()*target.defeat);
			target.beidaFn('普通伤害'+shanghai);
		}
		if(shanghai > 0)target.hp -= shanghai;
		if(target.hp <= 0)target.deadFn();
	}
	var str = $(".show").html();
	$(".show").html(str+this.name+"HP: "+this.hp+" "+target.name+"HP: "+target.hp+'</br>');
}
Hero.prototype.duobiFn = function(){
	console.log(this.name+'躲开了攻击');
}
Hero.prototype.beidaFn = function(msg){
	console.log(this.name+'被'+msg);
	var str = $(".show").html(); 
	$(".show").html(str+this.name+'被'+msg+'</br>');
}
Hero.prototype.deadFn = function(){
	console.log(this.name+'死了');
}
